# Contributor: Dermot Bradley <dermot_bradley@yahoo.com>
# Maintainer:
pkgname=stubbyboot
pkgver=1.0.2
pkgrel=2
pkgdesc="simple UEFI stub"
url="https://github.com/puzzleos/stubby"
arch="x86 x86_64 aarch64"
license="LGPL-2.1"
depends="$pkgname-efistub=$pkgver-r$pkgrel"
makedepends="
	gnu-efi-dev
	"
subpackages="
	$pkgname-efistub
	"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/puzzleos/stubby/archive/refs/tags/v$pkgver.tar.gz
	no-werror.patch
	"

builddir="$srcdir/stubby-$pkgver"

build() {
	make build
}

package() {
	install -Dm755 stubby-smash.1.sh -t "$pkgdir"/usr/bin/
	install -Dm755 stubby-smash.2.sh -t "$pkgdir"/usr/bin/
	case "$CARCH" in
		aarch64 )
			_archname="aa64" ;;
		x86 )
			_archname="ia32" ;;
		x86_64 )
			_archname="x64" ;;
	esac

	install -Dm755 stubby.efi \
		"$pkgdir"/usr/lib/$pkgname/linux$_archname.efi.stub
}

check() {
	make test
}

efistub() {
	pkgdesc="Linux UEFI stub from the stubby bootloader project"
	depends=
	provides="efistub"
	provider_priority=10 # lower than gummiboot

	amove usr/lib/$pkgname
}

sha512sums="
fae83c3a720bdb7d62be30856df9676dc1e85051b16d8d2c166e5b7be5fdc5d907e592f180500a3739af6bae8e44a60684a88f66877c0de2445f5257bf29f135  stubbyboot-1.0.2.tar.gz
85e5a8d2af96550f49ce07e4660fdbc036a9eab63e2dbc53e7c3896a3dbf0044f07990db9f3c7e8ecc28178bd1ea2a5ac448368789563b7275ab636f6665a1e2  no-werror.patch
"
